#include <iostream>
#include <vector>
#include <set>
using namespace std;

struct pa{
	int x;
	int y;
	bool operator=(const pa& apa)
	{
		return ((x == apa.x) && (y == apa.y));
	}
};

vector<vector<int>> quee(vector<vector<int>>& queens,vector<vector<int>>& king)
{
	set<pa> recset;
	for (int i = 0; i < queens.size(); ++i) {
		recset.insert({queens[i][0],queens[i][1]});
	}
	vector<vector<int>> res;
	int kingx=king[0][0];
	int kingy=king[0][1];
	vector<vector<int>> fang={{0,1},{0,-1},{1,0},{-1,0},{1,1},{-1,1},{1,-1},{-1,-1}};
	for(int i=0;i!=fang.size();++i){
		int posx=king[0][0];
		int posy=king[0][1];
		while(((posx<8) && (posx>=0)) && ((posy<8) && (posy>=0))){
			if(recset.find({posx,posy}) != recset.end()){
				res.push_back({posx,posy});
				break;
			}
			posx+=fang[i][0];
			posy+=fang[i][1];
		}
	}
	return res;
}


int main()
{
	vector<vector<int>> a={{0,1},{1,0},{4,0},{0,4},{3,3},{2,4}};
	vector<vector<int>> b={{0,0}};
	vector<vector<int>> res=quee(a,b);
	for(int i=0;i!=res.size();++i){
		cout<<res[i][0]<<" "<<res[i][1]<<endl;
	}
}
